//
//  ViewController.m
//  UI02 __第二题
//
//  Created by 洛洛大人 on 16/6/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatImageView];
}


-(void)creatImageView {
   
    UIImage *image = [UIImage imageNamed:@"BackGround.png"];
    

    UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:image];
    backgroundImageView.frame = [UIScreen mainScreen].bounds;
    [self.view addSubview:backgroundImageView];
    
    [backgroundImageView release];
    
    [self creatAnimationImage];
    [self creatAnimationImage2];
    [self creatAnimationImage3];
    [self creatFlowerImage];
    [self creatGuaImage];
    [self creatPlantsImage];

}


-(void)creatAnimationImage {
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BZombie1.tiff"]];
    animationImageView.frame = CGRectMake(150, 100, 250, 150);
    [self.view addSubview:animationImageView];
    [animationImageView release];
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:25];
    
    for(int i = 1; i <= 25; i++) {
        NSString *name = [NSString stringWithFormat:@"BZombie%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        [mutableArray addObject:animationImage];
        
    }
    animationImageView.animationImages = mutableArray;
    
    animationImageView.animationDuration = 1;
    [animationImageView startAnimating];
    
}


-(void)creatAnimationImage2 {
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BZombie1.tiff"]];
    animationImageView.frame = CGRectMake(150, 250, 250, 150);
    [self.view addSubview:animationImageView];
    [animationImageView release];
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:25];
    
    for(int i = 1; i <= 25; i++) {
        NSString *name = [NSString stringWithFormat:@"BZombie%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        [mutableArray addObject:animationImage];
        
    }
    animationImageView.animationImages = mutableArray;
    
    animationImageView.animationDuration = 1;
    [animationImageView startAnimating];
    
}

-(void)creatAnimationImage3 {
    UIImageView *animationImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BZombie1.tiff"]];
    animationImageView.frame = CGRectMake(150, 400, 250, 150);
    [self.view addSubview:animationImageView];
    [animationImageView release];
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:25];
    
    for(int i = 1; i <= 25; i++) {
        NSString *name = [NSString stringWithFormat:@"BZombie%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        [mutableArray addObject:animationImage];
        
    }
    animationImageView.animationImages = mutableArray;
    
    animationImageView.animationDuration = 1;
    [animationImageView startAnimating];
    
}






-(void)creatFlowerImage {
    UIImageView *flowerImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flower1.tiff"]];
    flowerImageView.frame = CGRectMake(50, 100, 150, 100);
    [self.view addSubview:flowerImageView];
    [flowerImageView release];
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:25];
    
    for(int i = 1; i <= 18; i++) {
        NSString *name = [NSString stringWithFormat:@"flower%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        [mutableArray addObject:animationImage];
        
    }
    flowerImageView.animationImages = mutableArray;
    
    flowerImageView.animationDuration = 1;
    [flowerImageView startAnimating];
    
}


-(void)creatGuaImage {
    UIImageView *guaImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gua1.tiff"]];
    guaImageView.frame = CGRectMake(50, 250, 150, 100);
    [self.view addSubview:guaImageView];
    [guaImageView release];
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:25];
    
    for(int i = 1; i <= 16; i++) {
        NSString *name = [NSString stringWithFormat:@"gua%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        [mutableArray addObject:animationImage];
        
    }
    guaImageView.animationImages = mutableArray;
    
    guaImageView.animationDuration = 1;
    [guaImageView startAnimating];
    
}

-(void)creatPlantsImage {
    UIImageView *plantsImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"plants1.tiff"]];
    plantsImageView.frame = CGRectMake(50, 400, 150, 100);
    [self.view addSubview:plantsImageView];
    [plantsImageView release];
    NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:25];
    
    for(int i = 1; i <= 9; i++) {
        NSString *name = [NSString stringWithFormat:@"plants%d.tiff", i];
        UIImage *animationImage = [UIImage imageNamed:name];
        [mutableArray addObject:animationImage];
        
    }
    plantsImageView.animationImages = mutableArray;
    
    plantsImageView.animationDuration = 1;
    [plantsImageView startAnimating];
    
}













- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
